<!--
 * @Descripttion: 
 * @version: 
 * @Author: Connor
 * @Date: 2020-10-16 11:58:42
 * @LastEditors: Connor
 * @LastEditTime: 2020-10-22 09:53:40
-->
<template>
 
      <el-tree
          :props="defaultProps"
          accordion
          :load="loadNode"
          lazy
          >
      </el-tree>

</template>

<script>
import {m} from "@/store/yg/common/local"
import {ajax} from '@/store/yg/common/utils'
import axios from "axios";
import * as constant from "@/store/yg/common/constant";

export default {
  props: ["tabValue"],
  data() {
      return {
        data:[],
        defaultProps: {
          children: 'children',
          label: 'label',
        }
    }
  },
  
  methods: {
     async loadNode(node, resolve) {
          if (node.level === 0) {
            var data = await this.queryDate(1,null);
           // console.log("data0",data);
            return resolve(data);
          } 
          //console.log("nooo",node.data.no);
          if(node.data.no) {
            var data =  await this.queryDate(node.data.level+1,node.data.no)
           //  console.log("data0"+node.data.level+1,data);
            return resolve(data);

          }
      },
      async queryDate(level,parentNo) {
          //console.log(this.$store.state.edit.modalLink.uri);
           var param = {
                type: this.tabValue,
                level: level,
                parentNo: parentNo
           };
          //console.log('param',param);
          const data = await ajax("getListByLevelAndType", param)
          //console.log('data1',data);
          
          return data;
       
      }
  }
}
</script>

<style>
.mail {
  text-align: left;
}

</style>
